//区域管理
var tableData = {
	url : ctp + "/areaController/areaSearch.shtml",
	propertys : [ "AREA_CODE", "AREA_SNAME", "AREA_LNAME", "USER_NAME",
			"ENABLED", "REC_TIME" ],
	hrefs : [ [ "function=areaEdit", "recId=REC_ID", "修改",
			"[AREA_CODE][1=false]" ] ],
	//selff : removeCheckbox,
	opers : true,
	startLoad : function() {
		getListData(this);
	}
};

function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
	
}
$(document).ready(function() {
	searchData();
});
function removeCheckbox() {
	$("input[name=checkId]").each(function() {
		if ($(this).val() == '71758') { // 全国的区域不能删除
			$(this).remove();// 取得对象移除
		}
	});
}

/*
 * 区域添加
 */
function areaAdd() {
	dialogWin(850, 450, ctp + "/areaController/areaAddshow.shtml", "添加区域");
}

/*
 * 修改区域
 */
function areaEdit(recId) {
	dialogWin(850, 450, ctp + "/areaController/areaUpdateShow.shtml?recId="
			+ recId, "修改区域");
}

/*
 * 修改删除
 */
function areaDelete() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("del('" + recIds + "')", "是否要删除所选记录吗？");
}
function del(recIds) {
	$.ajax({
		url : ctp + "/areaController/areaDelete.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("所选择的记录删除成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
				$.fn.zTree.init($("#ztree"), setting);
			} else {
				jalert(result);
			}
		}
	});
}

// 区域启用
function areaEnable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("areaEnables('" + recIds + "')", "是否要启用所选记录！");
}
function areaEnables(recIds) {
	$.ajax({
		url : ctp + "/areaController/areaEnable.shtml",
		data : {
			recIds : recIds
		},
		type : "POST",
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("所选择的记录启用成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}

	});
}
// 区域停用
function areaDisable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("areaDisables('" + recIds + "')", "是否要停用所选记录！");
}
function areaDisables(recIds) {
	$.ajax({
		url : ctp + "/areaController/areaDisable.shtml",
		data : {
			recIds : recIds
		},
		type : "POST",
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("所选择的记录停用成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}

	});
}